<?php
include '../include/functions.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//Dtd html 4.01 Transitional//EN"
"http://www.w3.org/tr/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/MAIN.dwt.php" codeOutsideHTMLIsLocked="false" -->
  <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>JoshHughes.com NFL Football Pool</title>
    <!-- InstanceEndEditable -->
	<link rel="stylesheet" href="http://football.joshhughes.com/css/NFL.css" type="text/css">
	<script src="http://football.joshhughes.com/scripts/prototype.js" type="text/javascript"></script>
	<script src="http://football.joshhughes.com/scripts/scriptaculous.js" type="text/javascript"></script>
	<script src="http://football.joshhughes.com/scripts/football.js" type="text/javascript"></script>
    <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
  </head>
<body>
<div id="pagewidth" >
	<div id="header" >
	
		<?PHP include_once("layout/header.html"); ?>
		
	</div>
			<div id="wrapper" class="clearfix" > 
			<div id="maincol" >

			<!-- InstanceBeginEditable name="Contents" -->

				<?
				
				if ($ID) {
					//Connect To Database
					dbConnect();
					
					//Write SQL Query to extract specified data
					$SQL = "Select * From Users, NFLUsers, NFLTeams WHERE (Users.ID=$ID) AND (NFLUsers.FavTeam = NFLTeams.TeamName) AND (NFLUsers.ID=$ID)";
					//Open Record Set using SQL Query
					$result = mysql_query($SQL) or die("Cannot query the database.<br/>");
					# Check to see is SQL returned any rows.
					$numRows = mysql_num_rows($result);
					if ($numRows == 0)
					{
						//Write SQL Query to extract specified data
						$SQL = "Select * From NFLUsers WHERE ID=$ID";
						//Open Record Set using SQL Query
						$result = mysql_query($SQL) or die("Cannot query the database.<br/>");
					}
				?>	<table width="500" cellpadding="5" cellspacing="0"> <?
					do{
					if (($myrow["Username"] != Null) || ($myrow["Username"] != "")) {
					?> <tr><td align="center" class="bluebg" height="1"><span class="whitelink"><? echo $myrow["Username"]; ?></span></td></tr>
					<tr><td class="bluebg">
					<table width="100%" cellspacing="0" cellpadding="3" border="0">
					<?
						echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td width=\"100\">Username:</td><td><B>".$myrow["Username"]."</B></td><td width=\"5%\">&nbsp;</td></tr>";
						echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>Real Name:</td><td><B>".ucfirst($myrow["Fname"])." ".ucfirst($myrow["Lname"])."</B></td><td width=\"5%\">&nbsp;</td></tr>";
						echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>Email Address:</td><td><B>";
						if ($myrow["ShowEmail"] == 0) {
							echo "<I>Private</I></B></td><td width=\"5%\">&nbsp;</td></tr>";
						} else {
							echo "<a href=\"mailto:".$myrow["Email"]."\" class=\"permLink\">".$myrow["Email"]."</a></B></td><td width=\"5%\">&nbsp;</td></tr>";
						}
						echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>Website:</td><td><B>";
						if (($myrow["Website"] == "") || ($myrow["Website"] == "http://")|| ($myrow["Website"] == NULL)) {
							echo "<I>None</I></B></td><td width=\"5%\">&nbsp;</td></tr>";
						} else {
							echo "<a href=\"".$myrow["Website"]."\" target=\"blank\" class=\"permLink\">".$myrow["Website"]."</a></B></td><td width=\"5%\">&nbsp;</td></tr>";
						}
						echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>Member Since:</td><td><B>".date('F jS, Y',strtotime($myrow["DateJoined"]))."</B></td><td width=\"5%\">&nbsp;</td></tr>";
						if($myrow["City"] != "")
						{
							echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>Favorite Team:</td><td><a href=\"".$myrow["URL"]."\" target=\"blank\" class=\"permLink\">".$myrow["City"]." ".$myrow["TeamName"]."</a> (".$myrow["Wins"]." - ".$myrow["Loses"].")</td><td width=\"5%\">&nbsp;</td></tr>";
							echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>&nbsp;</td><td align=\"left\"><Img src=\"../images/".$myrow["LogoPref"]."/".$myrow["FavTeam"].".gif\"></td><td width=\"5%\">&nbsp;</td></tr>";

						}
						else
						{
							echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>Favorite Team:</td><td><B><I>None Selected</I></B></td><td width=\"5%\">&nbsp;</td></tr>";
						}					
						echo "<tr bgcolor=\"#FFFFFF\"><td width=\"100%\" colspan=\"4\"><HR></td></tr>";
						echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>Current Score:</td><td><B>".$myrow["Score"]."</B></td><td width=\"5%\">&nbsp;</td></tr>";
						echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>Current Pool Rank:</td><td><B>".$myrow["Rank"]."</B></td><td width=\"5%\">&nbsp;</td></tr>";
						echo "<tr bgcolor=\"#FFFFFF\"><td width=\"5%\">&nbsp;</td><td>Current Weighted Score:</td><td><B>".$myrow["WeightedScore"]."</B></td><td width=\"5%\">&nbsp;</td></tr>";
						
					}//end if (($myrow["Username"] != Null...
					}while($myrow = mysql_fetch_array($result));
					?> <tr bgcolor="#FFFFFF"><td colspan="4">&nbsp;</td></tr></table></td></tr></table> <?
				}
				else
				{
					//Connect To Database
					dbConnect();
					//Write SQL Query to extract specified data
					$SQL = "SELECT Users.ID, Users.Username, Users.Fname, Users.Lname, Users.DateJoined, NFLUsers.ID FROM Users, NFLUsers WHERE Users.ID = NFLUsers.ID AND Users.flag = 1 ORDER BY Username";
					//Open Record Set using SQL Query
					$result = mysql_query($SQL) or die("Cannot query the database.<br/>");
					?>	
					<table width="500" cellpadding="5" cellspacing="0">
						<tr>
							<td align="center" class="bluebg" height="1"><span class="whitelink">NFL Pool Members</span></td>
						</tr>
						<tr>
							<td class="bluebg">
							<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
							<tr bgcolor="#FFFFFF">
								<TH width="5%">&nbsp;</TH>
								<TH width="30%" align="left">Username</TH>
								<TH width="30%" align="left">Real Name</TH>
								<TH width="30%" align="left">Member Since</TH>
								<TH width="5%">&nbsp</TH>
							</tr>
							<?
							$row=0;
							do{
								if (($myrow["Username"] != Null) || ($myrow["Username"] != ""))
								{
									$row++;
									echo "<tr bgcolor=\"".getRowColor($row)."\"><td>&nbsp;</td>
									<td><B><a href=\"".$PHP_SELF."?ID=".$myrow["ID"]."\" class=\"permLink\">".$myrow["Username"]."</a></B></td>
									<td>".ucfirst($myrow["Fname"])." ".ucfirst($myrow["Lname"])."</td>
									<td>".date('m/d/Y',strtotime($myrow["DateJoined"]))."</td><td>&nbsp;</td></tr>";
								}
							}while($myrow = mysql_fetch_array($result));
							
								echo "<tr bgcolor=\"".getRowColor($row)."\"><td colspan=\"5\"><hr/></td></table>";
							?>
							<div id="showMore" style="background-color: #FFF;">&nbsp; <img src="http://football.joshhughes.com/images/show_down.png" onclick="new Effect.toggle('showMore', 'blind');new Effect.toggle('NonNFLMembers', 'blind');" /> <a href="#" class="permLink" onclick="new Effect.toggle('NonNFLMembers', 'blind');new Effect.toggle('showMore', 'blind')">Show Other Members</a></div>
							<div id="NonNFLMembers" style="display:none; background-color: #FFF;">
							&nbsp; <img src="http://football.joshhughes.com/images/show_right.png" onclick="new Effect.toggle('NonNFLMembers', 'blind');new Effect.toggle('showMore', 'blind');" /><a href="#" class="permLink" onclick="new Effect.toggle('NonNFLMembers', 'blind');new Effect.toggle('showMore', 'blind');"> Hide Other Members</a>
								<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center">
								<?
								$row=0;
								//Write SQL Query to extract specified data
								$SQL = "SELECT ID, Username, Fname, Lname, DateJoined, NFL FROM Users WHERE NFL = 0 AND flag = 1 ORDER BY Username";
								//Open Record Set using SQL Query
								$result = mysql_query($SQL) or die("Cannot query the database.<br/>");
								do{
									if (($myrow["Username"] != Null) || ($myrow["Username"] != ""))
									{
										$row++;
										echo "<tr bgcolor=\"".getRowColor($row)."\"><td width=\"5%\">&nbsp;</td>
										<td width=\"30%\"><B><a href=\"".$PHP_SELF."?ID=".$myrow["ID"]."\" class=\"permLink\">".$myrow["Username"]."</a></B></td>
										<td width=\"30%\">".ucfirst($myrow["Fname"])." ".ucfirst($myrow["Lname"])."</td>
										<td width=\"30%\">".date('m/d/Y',strtotime($myrow["DateJoined"]))."</td><td width=\"5%\">&nbsp;</td></tr>";
									}
								}while($myrow = mysql_fetch_array($result));

								?>
									<tr bgcolor="#FFFFFF"><td colspan="5">&nbsp;</td></tr>
								</table>
							</div>
							</td>
						</tr>
					</table>
					<?
				 }//end if ($ID)  ?>

			<!-- InstanceEndEditable -->
			
			</div>
			<div id="leftcol" >
			
				<?PHP include_once("layout/left_column.php"); ?>
		
			</div>
			
		</div>
		
		<div id="footer" >
		
			<?PHP include_once("layout/footer.html"); ?>
			
		</div>
</div>
</body>
<!-- InstanceEnd --></html>